package com.example.test.tools;

import android.annotation.SuppressLint;

import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.example.test.global.Constant;

import java.io.File;
import java.text.SimpleDateFormat;

public class MyUtils {
    private static final String TAG = MyUtils.class.getSimpleName();

    /**
     * 输出日志到
     *
     * @param tag    日志TAG
     * @param logcat 日志信息
     */
    public static void writeLogcat(String tag, String logcat) {
        @SuppressLint("SimpleDateFormat")
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String nowData = TimeUtils.getNowString(sdf);
        String path = Constant.LOGCAT_OUTPUT_PATH + File.separator + nowData + ".txt";
        logcat = TimeUtils.getNowString() + "===" + tag + "===>" + logcat + "\n";
        FileIOUtils.writeFileFromString(new File(path), logcat, true);
    }
}
